package context.filter;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

public class EncodingMyFilter implements Filter{

	@Override
	public void destroy() {		
		
	}

	@Override
	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
			//사전작업...
			request.setCharacterEncoding("utf-8");
			response.setContentType("text/html;charset=utf-8");
			
			//PrintWriter out = response.getWriter();
			//out.println("<h2><b>Filtering이 진행중입니다....</b></h2><p>");
			
			//이부분이 있어야지만 다음 웹 컴포넌트로 요청이 이어진다.
			chain.doFilter(request, response); 
			
			//사후작업
			//out.println("<h2><b>이제 Filtering을 끝내겠습니다...</b></h2>");	
			
	}

	@Override
	public void init(FilterConfig arg0) throws ServletException {
				
	}
}















